﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Dev_house_Project.ViewModel;
using Dev_house_Project.ViewModel.Converters;
using Visifire.Charts;

namespace Dev_house_Project.GUI.Silverlight
{
    public partial class MainPage : UserControl
    {
       private MainViewModel _model;

        public MainPage()
        {
            InitializeComponent();

            _model = new MainViewModel();
            
            DataContext = _model;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_model_PropertyChanged);
            

        }

        void _model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var converter = new CompaniesToChartDataSeries();
            var series = (DataSeries)converter.Convert(_model.Companies, null, null, null);

            series.RenderAs = RenderAs.Column;
            Chart1.Series.Add((DataSeries)converter.Convert(_model.Companies, null, null, null));

            var series2 = series;
            series.RenderAs = RenderAs.Pie;
            Chart2.Series.Add(series2);
        }
    }
}
